package com.lvmama.rhino.service.impl;

import com.lvmama.entity.system.Menu;
import com.lvmama.entity.system.SysUser;
import com.lvmama.rhino.service.MenuService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("menuService")
public class MenuServiceImpl implements MenuService {

    /**
     * 查询权限信息
     *
     * @param user
     */
    @Override
    public List<Menu> getMenuList(SysUser user) {
        List<Menu> menus = user.getRoles().get(0).getMenuList();
        List<Menu> sysMenus = new ArrayList<>();
        for (Menu menu : menus) {
            if (user.getRemarks().equals(menu.getSysCode())) {
                sysMenus.add(menu);
            }
        }
        return sysMenus;
    }
}
